import { _decorator, Component, Node, RigidBodyComponent } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('characterRigid')
export class characterRigid extends Component {
    private _rigidBody: RigidBodyComponent = null!;


    /** 1 positive, 0 static, -1 negative */
    protected _stateX: number = 0;
    protected _stateZ: number = 0;
    /** 当前最大速度 */
    private _curMaxSpeed: number = 0;


    public initSpeed(moveSpeed: number, ratio: number = 1) {
        this._curMaxSpeed = moveSpeed * ratio;
    }



    /**
     * 刚体停止移动
     *
     */
    public stopMove() {
        this._stateX = 0;
        this._stateZ = 0;
        this.clearVelocity();
    }



    /**
     * 清除移动速度
     */
    public clearVelocity() {
        this._rigidBody.clearVelocity();
    }
}


